"use strict";(globalThis.webpackChunk_github_ui_github_ui=globalThis.webpackChunk_github_ui_github_ui||[]).push([["packages_app-uuid_app-uuid_ts-packages_repos-file-tree-view_repos-file-tree-view_ts"],{6873:(e,t,a)=>{a.r(t),a.d(t,{FileResultRow:()=>A,default:()=>B});var n=a(74848),i=a(31078),r=a(53552),l=a(6665),o=a(19189),s=a(78314),c=a(65787),d=a(25407),u=a(66108),m=a(94195),f=a(96459),p=a(11683),h=a(38621),x=a(45800),g=a(72511),y=a(5524),v=a(57352),w=a(31604),_=a(69726),R=a(87448),F=a(10095),b=a(91385),C=a(96540),N=a(7808),I=a(64642),T=a(76492),j=a(54030);let k={Box:"FileResultsList-module__Box--vA4S3",OverlayEnabled:"FileResultsList-module__OverlayEnabled--TR58f",ActionList:"FileResultsList-module__ActionList--_Vf2k",ActionList_Overlay:"FileResultsList-module__ActionList_Overlay--_kFTy",FilesSearchBox:"FileResultsList-module__FilesSearchBox--fSAh3",ActionList_ItemFocused:"FileResultsList-module__ActionList_ItemFocused--lCTMd",ActionList_Item:"FileResultsList-module__ActionList_Item--DMdMo",HighlightMatch:"FileResultsList-module__HighlightMatch--Is2AV",Octicon:"FileResultsList-module__Octicon--LtXx2",PrimerLink:"FileResultsList-module__PrimerLink--vMxOi"};var E=a(34164);let S={excludeDirectories:!1,excludeSeeAllResults:!1};function B({actionListClassName:e,additionalResults:t,commitOid:a,config:u=S,findFileWorkerPath:h,getItemUrl:_,onRenderRow:F,onItemSelected:b,searchBoxRef:B,className:A,sx:L}){let{excludeDirectories:P,excludeSeeAllResults:D}=u,{query:V,setQuery:H}=(0,i.JS)(),G=(0,s.t)(),W=C.useRef(null),z=B??W,[M,U]=C.useState(V.length>0),[K,q]=C.useState(!!V),{list:Z,directories:X,loading:Y,error:J}=(0,j.o)(a,M,!!P),{path:Q}=(0,r.eu)(),{getUrl:ee}=(0,o.Z)(),{queryText:et,queryLine:ea}=function(e){let t=(e=e.replaceAll(" ","")).indexOf(":");return t>=0?{queryText:e.substring(0,t),queryLine:parseInt(e.substring(t+1),10)}:{queryText:e,queryLine:void 0}}(V),{matches:en,clearMatches:ei}=function(e,t,a,n){let[i,r]=C.useState(),o=C.useRef(""),s=C.useRef(),{sendStats:c}=(0,l.T)(),d=C.useRef(!1),u=C.useCallback(()=>{let e=new N.z(a,I.j);e.onmessage=({data:e})=>{d.current=!1,r(e.list),o.current=e.query,e.startTime&&c("repository.find-file",{"find-file-base-count":e.baseCount,"find-file-results-count":e.list.length,"find-file-duration-ms":performance.now()-e.startTime})},s.current=e},[c,a]);return C.useEffect(()=>{if(n)return u(),function(){s.current?.terminate()}},[u,n]),C.useEffect(()=>{if(e.length&&t){d.current&&(s.current?.terminate(),u());let a=o.current&&t.startsWith(o.current);d.current=!0,s.current?.postMessage({baseList:a&&i||e,query:t,startTime:performance.now()})}},[e,t,u]),{matches:i,clearMatches:()=>r(void 0)}}((0,C.useMemo)(()=>[...Z,...t??[]].sort(),[t,Z]),et,h,M),{sendRepoClickEvent:er}=(0,l.T)(),el=(0,f.Z)(),[eo,es]=C.useState(0),[ec,ed]=C.useState(()=>(0,T.q)()),eu=C.useRef(null),em=C.useRef(null),ef="file-results-list",{sendRepoKeyDownEvent:ep}=(0,l.T)(),{screenSize:eh}=(0,m.lm)(),ex=u.enableOverlay??eh>=m.Gy.large,eg=C.useCallback(e=>{er("FILE_TREE.SEARCH_RESULT_CLICK"),b?.(e),q(!1)},[er,b]),ey=(e,t,a)=>_?_(e,t,a):ee({path:e,action:t?"tree":"blob",hash:a}),{containerRef:ev}=(0,x.G)({bindKeys:p.z0.ArrowVertical|p.z0.HomeAndEnd,focusInStrategy:"previous"},[Y,J]);C.useEffect(()=>{V||q(!1)},[V]),C.useEffect(()=>{document.activeElement!==z.current&&ex&&q(!1)},[Q,z,ex]);let ew=en?.slice(0,40)||[],e_=en&&en.length>ew.length,eR=(0,n.jsx)("div",{className:(0,E.$)(k.Box,{[k.OverlayEnabled]:ex}),children:J?(0,n.jsx)(g.A,{variant:"danger",className:"m-3",children:"Failed to search"}):(0,n.jsxs)(y.l,{ref:ev,className:(0,E.$)(e,k.ActionList,{[k.ActionList_Overlay]:ex}),role:"listbox",children:[!Y&&ew.map((e,t)=>{let a=X.includes(e),i=ey(e,a,ea?`L${ea}`:"");return(0,n.jsx)($,{active:e===Q,index:t,focused:ec&&eo===t,match:e,onRender:F,query:et,onClick:eg,isDirectory:a,to:i,useOverlay:ex,listRef:ev},e)}),(0,n.jsxs)("div",{className:"m-3 text-center",children:[(0,n.jsx)(O,{loading:Y||!en,visibleResultCount:ew.length,truncated:!!e_}),e_&&!D&&(0,n.jsxs)(n.Fragment,{children:["\xa0",(0,n.jsx)(v.A,{id:"see-all-results-link",className:(0,E.$)("focus-visible",{[k.PrimerLink]:ec&&eo===ew.length}),ref:eu,href:(0,d.Y8Y)({owner:G.ownerLogin,repo:G.name,searchTerm:`path:${et}`}),children:"See all results"})]})]})]})});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(R.az,{ref:em,sx:L,className:A,children:(0,n.jsx)(T.Z,{ariaActiveDescendant:(!ex&&V||ex&&K)&&ec&&eo>-1?e_&&eo===ew.length?"see-all-results-link":`file-result-${eo}`:void 0,ariaExpanded:ex?K:void 0,ariaHasPopup:ex,ariaControls:ex?ef:void 0,ref:z,query:V,onKeyDown:e=>{let{key:t,shiftKey:a,metaKey:n,altKey:i,ctrlKey:r}=e;if(!a&&!n&&!i){if("Escape"===t)V?(ep("FILE_TREE.CANCEL_SEARCH"),H(""),ei()):document.activeElement&&document.activeElement.blur();else if(!V)return;else if("Enter"===t){if(!D&&e_&&eo===ew.length)el((0,d.Y8Y)({owner:G.ownerLogin,repo:G.name,searchTerm:`path:${et}`})),b?.();else if(ew[eo]){let e=ew[eo];el(ey(ew[eo],!1,ea?`L${ea}`:"")),q(!1),b?.(e)}}else if("ArrowDown"===t||r&&"n"===t){if(!D&&e_&&eo>=ew.length-1){if(es(ew.length),eu.current&&ev.current){let e=(0,c.U)(ev.current);(0,p.Rt)(eu.current,e,{behavior:"instant"})}}else es(Math.min(eo+1,ew.length-1));e.preventDefault();return}else if("ArrowUp"===t||r&&"p"===t){es(Math.max(eo-1,0)),e.preventDefault();return}}},onPreload:()=>U(!0),onSearch:e=>{H(e),e?q(!0):(ei(),q(!1)),es(0)},onBlur:e=>{ev.current?.contains(e.relatedTarget)||(q(!1),ed(!1))},onFocus:()=>{V&&q(!0),ed(!0)},className:k.FilesSearchBox})}),ex&&(0,n.jsx)(w.T,{anchorRef:em,open:ex&&K,renderAnchor:null,onClose:()=>{q(!1)},focusZoneSettings:{disabled:!0},focusTrapSettings:{disabled:!0},width:"xlarge",align:"end",overlayProps:{id:ef,role:"dialog"},children:eR}),!ex&&V&&eR]})}function O({visibleResultCount:e,truncated:t,loading:a}){return(0,n.jsx)("span",{role:"status",className:a||t||0===e?void 0:"sr-only","aria-label":a?"Loading":void 0,children:a?(0,n.jsx)(_.A,{size:"large"}):0===e?"No matches found":t?`First ${e} files shown.`:`Showing ${e} files.`},"results-count-status")}let A=({active:e,focused:t,index:a,match:i,query:r,to:l,isDirectory:o,onClick:s,onRender:d,useOverlay:m,listRef:f})=>{let h=(0,b.Xq)(r,i);d?.();let x=C.useRef(null);C.useEffect(()=>{if(t&&x.current&&f?.current){let e=(0,c.U)(f.current);(0,p.Rt)(x.current,e,{behavior:"instant"})}},[t,f]);let g=(0,C.useCallback)(()=>{s?.(i)},[i,s]);return(0,n.jsx)(y.l.Item,{role:"group",active:e,className:(0,E.$)(t?k.ActionList_ItemFocused:void 0),children:(0,n.jsxs)(u.N,{to:l,ref:x,role:"option",onClick:g,id:`file-result-${a}`,tabIndex:m?-1:0,"data-focus-visible-added":t||void 0,className:(0,E.$)("d-flex",k.ActionList_Item),children:[(0,n.jsx)("div",{className:"d-flex flex-1 flex-column overflow-hidden",children:(0,n.jsx)(D,{text:i,positionsList:h,LeadingIcon:o?L:P,className:k.HighlightMatch})}),t&&(0,n.jsx)("div",{className:"sr-only",children:`Go to ${o?"folder":"file"}`})]})},i)},L=()=>(0,n.jsx)(F.A,{"aria-label":"Directory",icon:h.FileDirectoryFillIcon,size:"small",className:k.Octicon}),P=()=>(0,n.jsx)(F.A,{"aria-label":"File",icon:h.FileIcon,className:"fgColor-muted mr-2",size:"small"}),$=C.memo(A);function D({text:e,positionsList:t,className:a,LeadingIcon:i}){let r=[],l=0;for(let a of t){if(Number(a)!==a||ae.length)continue;let t=e.slice(l,a);t&&r.push(V(t)),l=a+1,r.push((0,n.jsx)("mark",{className:"text-bold bgColor-transparent fgColor-default",children:e[a]},a))}return r.push(V(e.slice(l))),(0,n.jsx)("div",{className:a,children:(0,n.jsxs)(n.Fragment,{children:[i&&(0,n.jsx)(i,{}),r]})})}function V(e){return e.replaceAll("/","/\u200B")}try{B.displayName||(B.displayName="FileResultsList")}catch{}try{O.displayName||(O.displayName="FileResultsStatus")}catch{}try{A.displayName||(A.displayName="FileResultRow")}catch{}try{L.displayName||(L.displayName="DirectoryIcon")}catch{}try{P.displayName||(P.displayName="FileResultIcon")}catch{}try{$.displayName||($.displayName="MemoizedFileResultRow")}catch{}try{D.displayName||(D.displayName="HighlightMatch")}catch{}},8624:(e,t,a)=>{a.d(t,{L:()=>s});var n=a(74848),i=a(21728),r=a(38621),l=a(26108),o=a(34164);let s=a(96540).forwardRef((e,t)=>{let a,s,c,d=(0,i.c)(17),{expanded:u,testid:m,ariaLabel:f,ariaControls:p,onToggleExpanded:h,alignment:x,dataHotkey:g,className:y,size:v,tooltipDirection:w,variant:_}=e,R=u?`collapse-${m}`:`expand-${m}`,F=u?"left"===x?r.SidebarExpandIcon:r.SidebarCollapseIcon:"left"===x?r.SidebarCollapseIcon:r.SidebarExpandIcon;d[0]!==h?(a=e=>{h(e)},d[0]=h,d[1]=a):a=d[1];let b=_??"invisible";return d[2]!==y?(s=(0,o.$)(y,"fgColor-muted"),d[2]=y,d[3]=s):s=d[3],d[4]!==p||d[5]!==f||d[6]!==g||d[7]!==u||d[8]!==t||d[9]!==v||d[10]!==R||d[11]!==F||d[12]!==a||d[13]!==b||d[14]!==s||d[15]!==w?(c=(0,n.jsx)(l.K,{"aria-label":f,tooltipDirection:w,ref:t,"data-testid":R,"aria-expanded":u,"aria-controls":p,icon:F,"data-hotkey":g,onClick:a,variant:b,size:v,className:s}),d[4]=p,d[5]=f,d[6]=g,d[7]=u,d[8]=t,d[9]=v,d[10]=R,d[11]=F,d[12]=a,d[13]=b,d[14]=s,d[15]=w,d[16]=c):c=d[16],c});s.displayName="ExpandButton"},12748:(e,t,a)=>{a.d(t,{_:()=>i});var n=a(74848);function i({buttonFocusId:e,buttonHotkey:t,onButtonClick:a,buttonTestLabel:i,onlyAddHotkeyScopeButton:r}){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{hidden:!0,"data-testid":i||"","data-hotkey":t,onClick:a,"data-hotkey-scope":e}),!r&&(0,n.jsx)("button",{hidden:!0,"data-hotkey":t,onClick:a})]})}try{i.displayName||(i.displayName="DuplicateOnKeydownButton")}catch{}},17182:(e,t,a)=>{a.d(t,{Nq:()=>M,H:()=>h,c2:()=>eu,Uy:()=>U,qn:()=>e_});var n=a(74848),i=a(12748),r=a(80780),l=a(8624),o=a(54571),s=a(38621),c=a(21373),d=a(34164),u=a(96540);let m={expandButton:"ExpandFileTreeButton-module__expandButton--oKI1R",filesButtonBreakpoint:"ExpandFileTreeButton-module__filesButtonBreakpoint--03FKA",Button_1:"ExpandFileTreeButton-module__Button_1--g8F6Q"},f=u.forwardRef(({expanded:e,onToggleExpanded:t,className:a,ariaControls:u,textAreaId:f,useFilesButtonBreakpoint:p=!0,variant:h,getTooltipDirection:x},g)=>{let{toggleTreeShortcut:y}=(0,r.wk)(),[v]=(0,o.I)(()=>!1,!0,[]),w=x?.(e)??"se";return(0,n.jsxs)(n.Fragment,{children:[p&&(!e||v)&&(0,n.jsx)(c.Q,{"aria-label":"Expand file tree",leadingVisual:s.ArrowLeftIcon,"data-hotkey":y.hotkey,"data-testid":"expand-file-tree-button-mobile",ref:g,onClick:t,variant:h??"invisible",className:m.Button_1,children:"Files"}),(0,n.jsx)(l.L,{dataHotkey:y.hotkey,className:(0,d.$)(a,"position-relative",m.expandButton,{[m.filesButtonBreakpoint]:p&&(!e||v)}),expanded:e,alignment:"left",ariaLabel:e?"Collapse file tree":"Expand file tree",tooltipDirection:w,testid:"file-tree-button",ariaControls:u,ref:g,variant:h,onToggleExpanded:t}),(0,n.jsx)(i._,{buttonFocusId:f,buttonHotkey:y.hotkey,onButtonClick:t,onlyAddHotkeyScopeButton:!0})]})});f.displayName="ExpandFileTreeButton";var p=a(6665);function h({inputRef:e,onFindFilesShortcut:t,textAreaId:a}){let{sendRepoKeyDownEvent:l}=(0,p.T)(),{findFilesShortcut:o}=(0,r.wk)();return(0,n.jsx)(i._,{buttonFocusId:a,buttonHotkey:o.hotkey,onButtonClick:()=>{t?.(),e?.current?.focus(),l("GO_TO_FILE")}})}try{h.displayName||(h.displayName="FindFilesShortcut")}catch{}var x=a(6873),g=a(93753),y=a(31078),v=a(46209),w=a(19189),_=a(78314),R=a(53419),F=a(25407),b=a(66108),C=a(94195),N=a(64830),I=a(96379),T=a(11683),j=a(73783),k=a(26108),E=a(87555),S=a(63307),B=a(10095),O=a(87448),A=a(27104);let L=(0,u.createContext)({knownFolders:new Map,dispatchKnownFolders:()=>{}});try{L.displayName||(L.displayName="FileTreeContext")}catch{}let P={Pane:"ReposFileTreePane-module__Pane--D26Sw",HidePane:"ReposFileTreePane-module__HidePane--a07q8",HidePaneWithTreeOverlay:"ReposFileTreePane-module__HidePaneWithTreeOverlay--CJn2n",Overlay:"ReposFileTreePane-module__Overlay--ynIDA",HideTree:"ReposFileTreePane-module__HideTree--IyYTf",Box_1:"ReposFileTreePane-module__Box_1--ZT_4S",Box_2:"ReposFileTreePane-module__Box_2--RgzGf",Box_3:"ReposFileTreePane-module__Box_3--XDLn8",Box_4:"ReposFileTreePane-module__Box_4--TLAAU",IconButton:"ReposFileTreePane-module__IconButton--fpuBk",FileResultsList:"ReposFileTreePane-module__FileResultsList--YEf_n",Box_5:"ReposFileTreePane-module__Box_5--cckih",Box_6:"ReposFileTreePane-module__Box_6--zVfxO",Box_7:"ReposFileTreePane-module__Box_7--v7doA",Box_8:"ReposFileTreePane-module__Box_8--KVzCi",FullWidthButtonGroup:"ReposFileTreePane-module__FullWidthButtonGroup--avF6A"};var $=a(53552),D=a(25556),V=a(34535),H=a(96459),G=a(40480),W=a(69726);let z=(0,u.createContext)({});function M({children:e}){let t=(0,u.useRef)(!1),a=(0,u.useRef)(!1),i=(0,u.useRef)(!0),r=(0,u.useCallback)(e=>{t.current=e},[]),l=(0,u.useCallback)(e=>{a.current=e},[]),o=(0,u.useCallback)(e=>{i.current=e},[]),s=(0,u.useMemo)(()=>({expandAllFolders:t,refreshTree:a,shouldFetchFolders:i,setExpandAllFolders:r,setRefreshTree:l,setShouldFetchFolders:o}),[r,l,o]);return(0,n.jsx)(z.Provider,{value:s,children:e})}function U(){return(0,u.useContext)(z)}try{z.displayName||(z.displayName="FileTreeControlContext")}catch{}try{M.displayName||(M.displayName="FileTreeControlProvider")}catch{}var K=a(52870);function q(e,t,a){let n=[];for(let i of t)if(i.startsWith(e)){let t=i.slice(e.length+1),r=t.indexOf("/"),l=r>0?t.slice(0,r):t,o=`${e}/${l}`;if(a&&a.some(e=>e.path===o))continue;let s={items:[],data:{contentType:o===i?"file":"directory",name:l,path:o,isClientOnly:!0}};n.push(s)}return n}function Z(e,t,a){e.data.name=e.data.name.slice(e.data.name.lastIndexOf("/")+1,e.data.name.length);let n=t.name.slice(0,t.name.lastIndexOf("/")),i=n.indexOf("/")>-1,r={path:t.path.slice(0,t.path.lastIndexOf("/")),contentType:t.contentType,name:n,hasSimplifiedPath:i},l={items:[e],data:r};return(a.set(r.path,l),i)?Z(l,{...r},a):l}let X={Box:"ReposFileTreeView-module__Box--bDodO",Box_1:"ReposFileTreeView-module__Box_1--Q_A5H",Octicon:"ReposFileTreeView-module__Octicon--XcIsb",Box_2:"ReposFileTreeView-module__Box_2--bCLXn"};function Y(e,t,a,n){if(!e)return{newRootItems:a,rootItemsUpdated:!1};let i=!!e[""]&&J("",t,a,e[""].items);for(let i of(n?.(a),Object.keys(e).sort()))if(i){let a=t.get(i);a&&(J(i,t,a.items,e[i].items,n),a.data.totalCount=e[i].totalCount)}return{newRootItems:a,rootItemsUpdated:i}}function J(e,t,a,n,i){let r=!1;for(let l of n){let n=e?`${e}/${l.name}`:l.name;if(!t.get(n)){let e={items:[],data:{...l}};if(t.set(n,e),l.hasSimplifiedPath){let n=Z(e,l,t),o=a.findIndex(e=>e.data.path===n.data.path);-1!==o?n.items.length>a[o].items.length&&(a[o]=n,r=!0):(a.push(n),i?.(a))}else a.push(e),i?.(a)}}return r}function Q({isActive:e,file:t,onItemSelected:a,getItemUrl:i,selectedItemRef:r,navigate:l,onRenderRow:o,getFileTrailingVisual:c,getFileIcon:d}){let{sendRepoClickEvent:m}=(0,p.T)(),f=u.useRef(null),h=(0,V.Z)({focusRowRef:f,mouseRowRef:f}),x="submodule"===t.data.contentType,g=c?.(t.data),y=u.useCallback(n=>{x?(n.preventDefault(),t.data.submoduleUrl&&(window.location.href=t.data.submoduleUrl)):n.metaKey||n.ctrlKey||1===n.button?(window.open(i(t.data),"_blank"),n.preventDefault()):e?n.preventDefault():(a?.(),m("FILES_TREE.ITEM",{item_path:t.data.path}),l(i(t.data)),n.stopPropagation())},[t.data,i,e,x,l,a,m]);return o?.(),(0,n.jsxs)(G.G.Item,{ref:f,onSelect:y,current:e,id:`${t.data.path}-item`,containIntrinsicSize:e?void 0:"auto 2rem",children:[(0,n.jsx)(G.G.LeadingVisual,{children:d?d(t.data):x?(0,n.jsx)(s.FileSubmoduleIcon,{}):(0,n.jsx)(s.FileIcon,{})}),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{ref:r,style:{color:x?"var(--fgColor-accent, var(--color-accent-fg))":void 0},children:t.data.name}),h&&(0,n.jsx)(D.m,{"data-testid":`${t.data.name}-item-tooltip`,id:`${t.data.name}-item-tooltip`,contentRef:f,"aria-label":t.data.name,open:!0,direction:"ne"})]}),!!g?.screenReaderText&&(0,n.jsx)("span",{className:"sr-only",children:g.screenReaderText}),!!g?.trailingVisual&&(0,n.jsx)(G.G.TrailingVisual,{children:g.trailingVisual})]})}let ee=u.memo(Q);function et({clientOnlyFilePaths:e,directory:t,isActive:a,isAncestorOfActive:i,leadingPath:r="",onItemSelected:l,dispatchKnownFolders:o,getItemUrl:s,getFetchUrl:c,selectedItemRef:d,navigate:m,onRenderRow:f,getFileTrailingVisual:h,getFileIcon:x,navigateOnClick:g=!0}){let{expandAllFolders:y,shouldFetchFolders:v}=U(),[w,_]=(0,u.useState)(y?.current||i),{sendRepoClickEvent:R}=(0,p.T)(),F=u.useRef(null),b=u.useRef(null),C=(0,V.Z)({focusRowRef:b,mouseRowRef:F}),[N,T,j,k,E,S,B]=function(e,t,a){let[n,i]=u.useState(e.items),[r,l]=u.useState(e.data.totalCount||0),[o,s]=u.useState(!1),[c,d]=u.useState(!1),{safeSetTimeout:m}=(0,K.A)();u.useEffect(()=>{i(e.items)},[e.items]),u.useEffect(()=>{void 0!==e.data.totalCount&&l(e.data.totalCount)},[e.data.totalCount]);let f=u.useCallback(()=>{d(!1)},[]),p=u.useCallback((e,t)=>{let a=e||[...n];i(a.slice(0,100)),m(()=>{i(a),void 0!==t&&l(t)},1)},[n,m]);return[u.useCallback(async n=>{let r=new Map;if(e.data.isClientOnly){if(n){let a=q(e.data.path,n);for(let e of a)r.set(e.data.path,e);t({type:"add",folders:r,processingTime:0}),a.length>100?p(a,a.length):(i(a),l(a.length))}}else{let o=a(e.data);d(!1),s(!0);let c=Date.now(),u=await (0,I.lS)(`${o}?noancestors=1`);try{if(u.ok){let a=await u.json(),o=a.payload.tree.items.map(e=>{let t={items:[],data:{...e},autoExpand:"directory"===e.contentType&&1===a.payload.tree.items.length};return(r.set(e.path,t),e.hasSimplifiedPath)?Z(t,e,r):t});if(n){let t=e.data.path,i=q(t,n,a.payload.tree.items);for(let e of(o.push(...i),i))r.set(e.data.path,e)}t({type:"add",folders:r,processingTime:Date.now()-c}),e.items=o,e.data.totalCount=a.payload.tree.totalCount,o.length>100?p(o,a.payload.tree.totalCount):(i(o),l(a.payload.tree.totalCount))}else d(!0)}catch{d(!0)}}s(!1)},[a,e,t,p]),p,n,o,c,f,r]}(t,o,c),O=B-j.length,A=r?`${r}/`:"";(0,u.useEffect)(()=>{y?.current&&!w&&_(!0)},[t,y,w]);let L=u.useCallback(n=>{y?.current&&(y.current=!1),n&&!w&&!k&&!E&&(t.items.length>100?T():0!==t.items.length||a||i||v?.current===!1||N(e)),n!==w&&_(n)},[y,w,k,E,t.items.length,a,i,v,T,N,e]),P=u.useCallback(e=>{e.metaKey||e.ctrlKey||1===e.button&&g?(window.open(s(t.data),"_blank"),e.preventDefault()):a?e.preventDefault():(l?.(),R("FILES_TREE.ITEM",{item_path:t.data.path}),g?m(s(t.data)):L?.(!w),e.stopPropagation())},[t.data,s,a,w,m,g,l,L,R]);u.useEffect(()=>{i&&!w&&L?.(!0)},[i]),u.useEffect(()=>{0===t.items.length&&w?L?.(!1):!w&&t.autoExpand&&L?.(!0)},[t.items.length]);let $=u.useCallback(e=>{d&&a&&d(e),F.current=e},[d,a]);return 1===t.items.length&&"directory"===t.items[0].data.contentType?(0,n.jsx)(ei,{clientOnlyFilePaths:e,directoryItems:t.items,leadingPath:A+t.data.name,inheritsActive:a,dispatchKnownFolders:o,onItemSelected:l,selectedItemRef:d,getItemUrl:s,directoryNavigateOnClick:g,getFileTrailingVisual:h,getFileIcon:x}):(f?.(),(0,n.jsxs)(G.G.Item,{ref:b,expanded:w,onExpandedChange:L,current:a,onSelect:P,id:`${t.data.path}-item`,containIntrinsicSize:a?void 0:"auto 2rem",children:[(0,n.jsx)(G.G.LeadingVisual,{children:(0,n.jsx)(G.G.DirectoryIcon,{})}),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{ref:$,children:[A,t.data.name]}),C&&(0,n.jsx)(D.m,{"data-testid":`${t.data.name}-directory-item-tooltip`,id:`${t.data.name}-directory-item-tooltip`,contentRef:b,"aria-label":`${A}${t.data.name}`,open:!0,direction:"ne"})]}),(0,n.jsx)(G.G.SubTree,{state:k?"loading":E?"error":"done",children:E?(0,n.jsx)(G.G.ErrorDialog,{onRetry:N,onDismiss:S,children:"There was an error loading the folder contents."}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ei,{clientOnlyFilePaths:e,directoryItems:j,dispatchKnownFolders:o,onItemSelected:l,selectedItemRef:d,getItemUrl:s,directoryNavigateOnClick:g,getFileTrailingVisual:h,getFileIcon:x}),O>0&&(0,n.jsx)(el,{message:`${O} entries not shown`})]})})]}))}let ea=u.memo(et);function en({clientOnlyFilePaths:e,directoryItems:t,leadingPath:a,inheritsActive:i,onItemSelected:r,dispatchKnownFolders:l,selectedItemRef:o,onRenderRow:s,getItemUrl:c,getFileTrailingVisual:d,getFileIcon:m,directoryNavigateOnClick:f=!0}){let{path:p}=(0,$.eu)(),h=(0,w.Z)(),x=(0,H.Z)(),g=u.useRef(x);return(0,n.jsx)(n.Fragment,{children:t.map(t=>{let u=p===t.data.path,x=u||p.startsWith(`${t.data.path}/`);return"directory"===t.data.contentType?(0,n.jsx)(ea,{clientOnlyFilePaths:e,isActive:i||u,isAncestorOfActive:x,onItemSelected:r,leadingPath:a,directory:t,dispatchKnownFolders:l,getItemUrl:c,getFetchUrl:h.getItemUrl,selectedItemRef:x?o:void 0,navigate:g.current,onRenderRow:s,navigateOnClick:f,getFileTrailingVisual:d,getFileIcon:m,itemCount:t.items.length},t.data.name):(0,n.jsx)(ee,{onItemSelected:r,file:t,isActive:u,getItemUrl:c,selectedItemRef:u?o:void 0,navigate:g.current,onRenderRow:s,getFileTrailingVisual:d,getFileIcon:m},t.data.name)})})}let ei=u.memo(en);function er(e){let{clientOnlyFilePaths:t,data:a,rootItems:i,setRootItems:r,fetchError:l,incompleteFileTree:o,processingTime:s,loading:c,onRenderRow:m,getItemUrl:f,getFileTrailingVisual:p,getFileIcon:h,sortDirectoryItems:x}=e,{knownFolders:g,dispatchKnownFolders:y}=(0,u.useContext)(L),{refreshTree:v}=U();u.useEffect(()=>{if(c)return;let e=new Map,t=[];v?.current||(e=new Map(g),t=i.slice());let{newRootItems:n,rootItemsUpdated:l}=Y(a,e,t,x);(n.length>i.length||l||v?.current)&&r(n),(e.size>g.size||v?.current)&&y({type:"set",folders:e,processingTime:s}),v?.current&&(v.current=!1)},[a,c]);let w=u.useCallback(e=>{1===e.button&&e.preventDefault()},[]);return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("div",{onMouseDown:w,className:(0,d.$)(e.className,X.Box),"data-testid":"repos-file-tree-container",children:c?(0,n.jsx)("div",{className:X.Box_1,children:(0,n.jsx)(W.A,{"aria-label":"Loading file tree"})}):(0,n.jsx)("nav",{"aria-label":"File Tree Navigation",children:(0,n.jsxs)(G.G,{"aria-label":"Files",children:[l&&(0,n.jsx)(el,{message:"Some files could not be loaded."}),o&&(0,n.jsx)(el,{message:"Sign in to see the full file tree."}),(0,n.jsx)(ei,{clientOnlyFilePaths:t,directoryItems:i,onItemSelected:e.onItemSelected,dispatchKnownFolders:y,selectedItemRef:e.selectedItemRef,onRenderRow:m,directoryNavigateOnClick:e.directoryNavigateOnClick,getItemUrl:f,getFileTrailingVisual:p,getFileIcon:h})]})})})})}function el({message:e}){return(0,n.jsxs)(G.G.Item,{id:"error-tree-row",children:[(0,n.jsx)(G.G.LeadingVisual,{children:(0,n.jsx)(B.A,{icon:s.AlertFillIcon,className:X.Octicon})}),(0,n.jsx)("div",{className:X.Box_2,children:e||"Couldn't load."})]})}try{Q.displayName||(Q.displayName="WrappedFileTreeRow")}catch{}try{ee.displayName||(ee.displayName="FileTreeRow")}catch{}try{et.displayName||(et.displayName="WrappedDirectoryTreeRow")}catch{}try{ea.displayName||(ea.displayName="DirectoryTreeRow")}catch{}try{en.displayName||(en.displayName="WrappedDirectoryContents")}catch{}try{ei.displayName||(ei.displayName="DirectoryContents")}catch{}try{er.displayName||(er.displayName="ReposFileTreeView")}catch{}try{el.displayName||(el.displayName="ErrorTreeRow")}catch{}var eo=a(23451);let es={IconButton:"SearchButton-module__IconButton--kxA3Q"};function ec({sx:e,onClick:t,textAreaId:a}){let{searchShortcut:l}=(0,r.wk)();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(O.K0,{"aria-label":"Search this repository",tooltipDirection:"nw",icon:s.SearchIcon,"data-hotkey":l.hotkey,sx:e,size:"medium",onClick:e=>{t?.(),(0,eo.Z)({retainScrollPosition:!0,returnTarget:e.target.closest("button")})},className:es.IconButton}),(0,n.jsx)(i._,{buttonFocusId:a,buttonHotkey:l.hotkey,onButtonClick:()=>{let e=document.getElementById(a);t?.(),(0,eo.Z)({retainScrollPosition:!0,returnTarget:e??void 0})},onlyAddHotkeyScopeButton:!0})]})}try{ec.displayName||(ec.displayName="SearchButton")}catch{}let ed=C.Gy.xxxlarge;function eu({clientOnlyFilePaths:e,collapseTree:t,showTree:a,fileTree:i,treeToggleElement:r,treeToggleRef:l,onItemSelected:c,processingTime:m,searchBoxRef:f,repo:p,path:R,refInfo:$,isFilePath:D,foldersToFetch:V,incompleteFileTree:H,id:G,onFindFilesShortcut:W,textAreaId:z,getItemUrlOverride:M,headerClassName:U,paneClassName:K,paneContentsClassName:q,treeContainerClassName:Z,findFileWorkerPath:X,headerContent:J,getFileTrailingVisual:Q,getFileIcon:ee,sortDirectoryItems:et,showFindFile:ea=!0,directoryNavigateOnClick:en=!0,showRefSelectorRow:ei=!0,paneResizable:el=!0}){if(ea&&void 0===X)throw Error("findFileWorkerPath must be provided when showFindFile is true");let{openPanel:eo}=(0,v.Ak)(),[es,eu]=u.useState(V.length>0),[ep,eh]=u.useState(!1),ex=u.useRef([]),eg=u.useRef(null),ey=u.useRef(!1),ev=u.useRef(!1),ew=u.useRef(null),{query:e_}=(0,y.JS)(),eR=u.useRef(e_);eR.current=e_;let{codeCenterOption:eF}=(0,N.ud)(),eb=u.useRef(eo),[eC]=(0,o.I)(()=>!1,!0,[]),{getItemUrl:eN}=(0,w.Z)(),eI=M||eN,{defaultBranch:eT}=(0,_.t)(),ej=[],ek=new Map,eE=u.useRef(es);!eE.current&&i&&(ej=Y(i,ek,[],et).newRootItems),eE.current=!0;let[eS,eB]=u.useReducer(em,ek),[eO,eA]=u.useState(ej);u.useEffect(()=>{a&&(!e_||window.innerWidth>=C.Gy.large)||(ew.current=null)},[a,e_]),u.useEffect(()=>{eo&&eb.current!==eo&&window.innerWidth{let t=eN({contentType:"directory",path:e,name:e});try{let a=await (0,I.lS)(`${t}?noancestors=1`);if(a.ok){let t=await a.json(),n={items:t.payload.tree.items,totalCount:t.payload.tree.totalCount};i[e]=n}else eh(!0)}catch{eh(!0)}ex.current.push(e),ex.current.length===V.length&&eu(!1)},[i,V.length,eN]);u.useEffect(()=>{if(H)eu(!1);else if(V&&!ey.current)for(let e of V)eL(e);ey.current=!0},[eL,V,H,eS.size]);let eP=u.useCallback(e=>{a&&(!eR.current||window.innerWidth>=C.Gy.large)&&eg.current&&e&&(0,T.Rt)(e,eg.current,{endMargin:window.innerHeight/2,startMargin:window.innerHeight/2,behavior:"auto"})},[a]),e$=u.useCallback(e=>{e&&ev.current?ev.current=!1:ew.current!==e&&eP(e),ew.current=e},[eP]),eD=u.useCallback(e=>{eg.current=e,window.innerWidth>=ed&&eP(ew.current)},[eP]),eV=u.useCallback(e=>{e&&eP(ew.current)},[eP]),{screenSize:eH}=(0,C.lm)(),eG=!eC&&(eo&&eH=C.Gy.large,eW=u.useCallback(()=>{eG||c(),ev.current=!0},[c,eG]),ez=D?R.substring(0,R.lastIndexOf("/")):R,eM=(0,u.useMemo)(()=>({knownFolders:eS,dispatchKnownFolders:eB}),[eS]),eU=u.useMemo(()=>eC?null:(0,A.KF)(),[eC]),eK=u.useCallback(()=>{window.innerWidth>C.Gy.large&&window.innerWidth0;return(0,R.BI)("file-tree",{"fetch-count":a?t.folders.size-e.size:t.folders.size,"file-count":t.folders.size,"nav-type":a?"soft":"hard","processing-time":t.processingTime}),t.folders}case"add":{let a=new Map([...e,...t.folders]);return(0,R.BI)("file-tree",{"fetch-count":t.folders.size,"file-count":a.size,"nav-type":"fetch","processing-time":t.processingTime}),a}default:throw Error(`Unknown action type: ${t.type}`)}}function ef({scrollingRef:e}){let[t,a]=u.useState(e.current&&e.current.scrollTop>0);return u.useEffect(()=>{if(e.current){let t=e.current,n=()=>{t&&t.scrollTop>0?a(!0):a(!1)};return t.addEventListener("scroll",n),()=>{t.removeEventListener("scroll",n)}}},[e]),t?(0,n.jsx)("div",{className:P.Box_8}):null}try{eu.displayName||(eu.displayName="ReposFileTreePane")}catch{}try{ef.displayName||(ef.displayName="TreeBorder")}catch{}var ep=a(76492),eh=a(31315),ex=a(35898),eg=a(71315),ey=a(88431),ev=a(81960);let ew={Heading:"use-tree-pane-module__Heading--iI_ad"};function e_(e,t,a,i,r,l="fileTreeExpanded",o){let{sendRepoClickEvent:s}=(0,p.T)(),c=(0,ex.i)(),d=l?(0,eh.Ri)(l):void 0,m=void 0===eg.XC,h=!c&&d&&"false"!==d.value||c&&a;void 0===h&&(h=!1);let x=(0,u.useRef)(null),g=(0,u.useRef)(null),{screenSize:y}=(0,C.lm)(),[v,w]=(0,u.useState)(h),_=(0,u.useRef)(h),R=(0,u.useRef)(!1),F=(0,u.useRef)(!1),b=(0,u.useCallback)(()=>!(t.current&&window.innerWidth>=ed||!t.current&&window.innerWidth>=C.Gy.xlarge),[t]);(0,ey.N)(()=>{let e=b();e||(R.current=!1),w((0,ep.q)()&&y{let e=!t.current&&window.innerWidth=C.Gy.xlarge;e&&_.current&&!(0,ep.q)()&&v&&w(!1),a&&_.current&&!v&&w(!0)},[t,y]),(0,ey.N)(()=>{let e=t.current&&window.innerWidth=ed;e&&_.current&&!(0,ep.q)()&&v&&w(!1),a&&_.current&&!v&&w(!0)},[t]);let N=(0,u.useCallback)(e=>{if(w(!0),b()&&(R.current=!0),e?.setPreference&&(r?.(!0),_.current=!0,l)){let e=new Date(Date.now()+2592e6).toUTCString();(0,eh.TV)(l,"true",e)}e?.focus==="toggleButton"?requestAnimationFrame(()=>x.current?.focus()):e?.focus==="search"&&requestAnimationFrame(()=>g.current?.focus())},[l,2592e6,b,r]),I=(0,u.useCallback)(e=>{if(w(!1),R.current=!1,F.current=!0,e?.setPreference&&(r?.(!1),_.current=!1,l)){let e=new Date(Date.now()+2592e6).toUTCString();(0,eh.TV)(l,"false",e)}e?.focus==="toggleButton"&&requestAnimationFrame(()=>x.current?.focus())},[l,2592e6,r]),T=(0,u.useCallback)(e=>e&&window.innerWidth>=ed||!t.current&&window.innerWidth>=C.Gy.xlarge,[t]),j=(0,u.useMemo)(()=>(0,n.jsx)(ev.A,{as:"h2",className:ew.Heading,children:(0,n.jsx)(f,{expanded:v,ariaControls:e,onToggleExpanded:()=>{s(v?"FILES_TREE.HIDE":"FILES_TREE.SHOW"),v?I({focus:"toggleButton",setPreference:T(t.current)}):N({focus:"toggleButton",setPreference:T(t.current)})},className:void 0!==d||v||m?void 0:"react-tree-toggle-button-with-indicator",ref:x,textAreaId:i,...o})}),[v,e,d,m,i,o,s,I,T,t,N]);return{isTreeExpanded:v,expandTree:N,collapseTree:I,treeToggleElement:j,treeToggleRef:x,searchBoxRef:g}}},23451:(e,t,a)=>{a.d(t,{Z:()=>n});function n({appendQuery:e,retainScrollPosition:t,returnTarget:a}){window.dispatchEvent(new CustomEvent("blackbird_monolith_append_and_focus_input",{detail:{appendQuery:e,retainScrollPosition:t,returnTarget:a}}))}},31315:(e,t,a)=>{function n(e){return i(e)[0]}function i(e){let t=[];for(let a of function(){try{return document.cookie.split(";")}catch{return[]}}()){let[n,i]=a.trim().split("=");e===n&&void 0!==i&&t.push({key:n,value:i})}return t}function r(e,t,a=null,n=!1,i="lax"){let l=document.domain;if(null==l)throw Error("Unable to get document domain");l.endsWith(".github.com")&&(l="github.com");let o="https:"===location.protocol?"; secure":"",s=a?`; expires=${a}`:"";!1===n&&(l=`.${l}`);try{document.cookie=`${e}=${t}; path=/; domain=${l}${s}${o}; samesite=${i}`}catch{}}function l(e,t=!1){let a=document.domain;if(null==a)throw Error("Unable to get document domain");a.endsWith(".github.com")&&(a="github.com");let n=new Date(Date.now()-1).toUTCString(),i="https:"===location.protocol?"; secure":"",r=`; expires=${n}`;!1===t&&(a=`.${a}`);try{document.cookie=`${e}=''; path=/; domain=${a}${r}${i}`}catch{}}a.d(t,{OR:()=>i,Ri:()=>n,TV:()=>r,Yj:()=>l})},46209:(e,t,a)=>{a.d(t,{Ak:()=>m,cD:()=>u,iK:()=>d});var n=a(74848),i=a(41617),r=a(35898),l=a(82075),o=a(94195),s=a(96540);let c=(0,l.A)("localStorage"),d=(0,s.createContext)({openPanel:void 0,setOpenPanel:()=>void 0});function u({children:e,payload:t,openPanelRef:a}){let l="blame"in t,u=(0,i.Hf)(t),m=(0,r.i)(),f=(0,s.useRef)(void 0),[p,h]=(0,s.useState)(()=>{let e=c.getItem("codeNavOpen");if(!m&&""!==e&&null!==e||m&&t.symbolsExpanded)return"codeNav"}),x=(l||u)&&"codeNav"===p?void 0:p;s.useEffect(()=>{a.current=x},[x,a]);let g=(0,s.useCallback)((e,t)=>{h(a=>(a&&f.current&&f.current.focus(),f.current=t,l||u&&"codeNav"===e?void 0:e))},[l,u]);var y=g;let{screenSize:v}=(0,o.lm)(),w=(0,s.useRef)(v);(0,s.useEffect)(()=>{let e=w.current>=o.Gy.large,t=w.current===v;v({openPanel:x,setOpenPanel:g}),[x,g]);return(0,n.jsx)(d.Provider,{value:_,children:e})}function m(){return(0,s.useContext)(d)}try{d.displayName||(d.displayName="OpenPanelContext")}catch{}try{u.displayName||(u.displayName="OpenPanelProvider")}catch{}},52475:(e,t,a)=>{a.d(t,{_S:()=>r,cB:()=>o,cW:()=>l});var n=a(53627),i=a(71315);let r=()=>{let e=(0,n.JV)().appId;return e&&"rails"!==e?e:crypto.randomUUID()},l=e=>{(0,n.C3)({appId:e})},o=()=>{let e=document.querySelector("react-app")||document.querySelector("projects-v2");return e?.uuid||"rails"};i.cg?.addEventListener("hashchange",()=>{(0,n.C3)({appId:o()})},!0)},64830:(e,t,a)=>{a.d(t,{T2:()=>c,cp:()=>p,ud:()=>x});var n=a(74848),i=a(21728),r=a(82075),l=a(96540);let o=(0,r.A)("localStorage"),s="codeView.codeFolding",c="codeView.codeWrapping",d="codeView.centerView",u="codeView.openSymbolsOnClick",m=new Map([[s,"Show code folding buttons"],[c,"Wrap lines"],[d,"Center content"],[u,"Open symbols on click"]]),f=(0,l.createContext)({codeFoldingOption:{},codeWrappingOption:{},codeCenterOption:{},openSymbolsOption:{}}),p=e=>{let t,a,r=(0,i.c)(8),{children:l}=e,o=h(s,!0),m=h(c,!1),p=h(d,!1),x=h(u,!0);r[0]!==p||r[1]!==o||r[2]!==m||r[3]!==x?(t={codeFoldingOption:o,codeWrappingOption:m,codeCenterOption:p,openSymbolsOption:x},r[0]=p,r[1]=o,r[2]=m,r[3]=x,r[4]=t):t=r[4];let g=t;return r[5]!==l||r[6]!==g?(a=(0,n.jsx)(f.Provider,{value:g,children:l}),r[5]=l,r[6]=g,r[7]=a):a=r[7],a};function h(e,t){let a,n,r,s,c=(0,i.c)(11);c[0]!==e?(a=o.getItem(e),c[0]=e,c[1]=a):a=c[1];let d=a;c[2]!==t||c[3]!==d?(n=()=>d?"true"===d:t,c[2]=t,c[3]=d,c[4]=n):n=c[4];let[u,f]=(0,l.useState)(n);c[5]!==e?(r=m.get(e)||"",c[5]=e,c[6]=r):r=c[6];let p=r;return c[7]!==u||c[8]!==p||c[9]!==e?(s={name:e,enabled:u,setEnabled:f,label:p},c[7]=u,c[8]=p,c[9]=e,c[10]=s):s=c[10],s}function x(){return(0,l.useContext)(f)}try{f.displayName||(f.displayName="CodeViewOptionsContext")}catch{}try{p.displayName||(p.displayName="CodeViewOptionsProvider")}catch{}},76492:(e,t,a)=>{a.d(t,{Z:()=>m,q:()=>f});var n=a(74848),i=a(70170),r=a(37272),l=a(6665),o=a(71315),s=a(38621),c=a(87448),d=a(96540),u=a(34164);let m=d.forwardRef(({ariaActiveDescendant:e,ariaControls:t,ariaExpanded:a,ariaHasPopup:o,onBlur:m,onFocus:p,onKeyDown:h,onPreload:x,onSearch:g,query:y,sx:v,className:w},_)=>{let{sendRepoClickEvent:R}=(0,l.T)(),[F,b]=d.useState(y),C=d.useRef((0,i.s)(e=>g(e),250));d.useEffect(()=>{b(y)},[y]);let N=y?(0,n.jsx)(c.ks.Action,{onClick:()=>{R("FILE_TREE.CANCEL_SEARCH"),g("")},icon:s.XCircleFillIcon,"aria-label":"Clear",className:"fgColor-muted"}):void 0;return(0,n.jsx)(c.ks,{autoFocus:f(),ref:_,value:F,onKeyDown:h,onChange:e=>{b(e.target.value),x(),C.current(e.target.value)},sx:v,className:(0,u.$)("d-flex",w),"aria-label":"Go to file","aria-activedescendant":e,role:o?"combobox":void 0,"aria-controls":t,"aria-expanded":a,"aria-haspopup":o?"dialog":void 0,autoCorrect:"off",spellCheck:"false",placeholder:"Go to file",leadingVisual:s.SearchIcon,trailingAction:N,trailingVisual:N?void 0:()=>(0,n.jsx)(r.E,{children:(0,n.jsx)("kbd",{children:"t"})}),onFocus:e=>{x(),e.target.select(),p?.(e)},onBlur:m,onClick:()=>R("FILE_TREE.SEARCH_BOX")})});function f(){return"1"===new URLSearchParams(o.fV.search).get("search")}m.displayName="FilesSearchBox"}}]); //# sourceMappingURL=packages_app-uuid_app-uuid_ts-packages_repos-file-tree-view_repos-file-tree-view_ts-03f2e34fa041.js.map